import 'package:get/get.dart';
import 'package:nyh_motorcade_app/constant/constant.dart';
import 'package:nyh_motorcade_app/utils/toast_utils.dart';

class SelectDateController extends GetxController {
  String startDate = "";
  String endDate = "";

  void setStartDate(String value) {
    startDate = value;
    update();
  }

  void setEdnDate(String value) {
    endDate = value;
    update();
  }

  void onConfirm() {
    if (startDate.isEmpty || endDate.isEmpty) {
      return;
    }
    if (DateTime.parse(endDate).isBefore(DateTime.parse(startDate))) {
      ToastUtils.toast("开始日期不能大于结束日期");
      return;
    }

    Get.back(result: {
      Constant.PARAM_START_DATE: startDate,
      Constant.PARAM_END_DATE: endDate,
    });
  }
}
